#! /user/bin/python3
# coding-utf-8
# @Time = 2025/4/10 14:48
# @Author:Poolaris

import ddddocr
import os


class OcrIdentify:
    # 初始化ocr实例
    def __init__(self):
        # 初始化 OCR 实例
        self.ocr = ddddocr.DdddOcr()

    def identify(self, image_path):
        # 验证图片路径
        if not os.path.exists(image_path):
            raise FileNotFoundError(f"图片 {image_path} 不存在")

        # 读取图片
        with open(image_path, "rb") as f:
            image = f.read()

            # 调用 OCR 识别
        res = self.ocr.classification(image)
        return res


# if __name__ == '__main__':
    # print(OcrIdentify().identify("test1.png"))
